package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.adapter.InviteFriendsAdapter;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.InviteFriendBean;
import com.appwoo.txtws.bean.PageBean;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.LoginService;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class InviteActivity extends AppActivity
  implements View.OnClickListener
{
  private int Logchange = 1;
  private TextView btn_invite_already;
  private TextView btn_invite_success;
  private InviteFriendsAdapter fAdapter = null;
  private List<InviteFriendBean> f_alreadyList = null;
  private List<InviteFriendBean> f_newList = null;
  private List<InviteFriendBean> f_newList_suc = null;
  private LinearLayout linear_list_title;
  private ListView listView_invite;
  private LoginService loginService = null;
  private int page;
  private TextView textview_invite_action;
  private TextView textview_invite_sumfriends;
  private TextView tf_line_already;
  private TextView tf_line_success;
  private String userName = "";
  private ProgressDialog v_progressDialog;

  private void addListener()
  {
    this.textview_invite_sumfriends.setOnClickListener(this);
    this.textview_invite_action.setOnClickListener(this);
    this.btn_invite_already.setOnClickListener(this);
    this.btn_invite_success.setOnClickListener(this);
    addMoreListListener();
  }

  private void addMoreListListener()
  {
    this.listView_invite.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()))
          new InviteActivity.InviteAsyncTask(InviteActivity.this).execute(new String[] { "more" });
      }
    });
  }

  private String bgInitAlreadyList()
  {
    try
    {
      this.page = 1;
      this.f_alreadyList = this.loginService.getSHF(this.userName, "", "0", this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgInitSuccessList()
  {
    try
    {
      this.page = 1;
      this.f_alreadyList = this.loginService.getSHF(this.userName, "", "1", this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgMoreAlreadyList()
  {
    try
    {
      this.page = (1 + this.page);
      this.f_newList = this.loginService.getSHF(this.userName, "", "0", this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private String bgMoreSuccessList()
  {
    try
    {
      this.page = (1 + this.page);
      this.f_newList_suc = this.loginService.getSHF(this.userName, "", "1", this.page, this);
      return "";
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private void bgShowAlready()
  {
    this.listView_invite.setAdapter(getAlreadyAdapter(this.f_alreadyList));
    this.textview_invite_sumfriends.setText(getString(2131427723) + PageBean.totalRecord + getString(2131427724));
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
      if (!this.v_progressDialog.isShowing())
        this.v_progressDialog.show();
    }
  }

  private InviteFriendsAdapter getAlreadyAdapter(List<InviteFriendBean> paramList)
  {
    if (paramList != null);
    try
    {
      this.fAdapter = new InviteFriendsAdapter(this, paramList);
      this.fAdapter.notifyDataSetChanged();
      label24: return this.fAdapter;
    }
    catch (Exception localException)
    {
      break label24;
    }
  }

  private void init()
  {
    this.userName = new RqSP().getLgAccount(this);
    this.loginService = new LoginService();
    this.textview_invite_sumfriends = ((TextView)findViewById(2131493148));
    this.textview_invite_action = ((TextView)findViewById(2131493149));
    this.btn_invite_already = ((TextView)findViewById(2131493138));
    this.btn_invite_success = ((TextView)findViewById(2131493139));
    this.listView_invite = ((ListView)findViewById(2131493146));
    this.linear_list_title = ((LinearLayout)findViewById(2131493142));
    this.tf_line_already = ((TextView)findViewById(2131493140));
    this.tf_line_success = ((TextView)findViewById(2131493141));
  }

  private void initActionBar()
  {
    hideBarHome();
    setBarTitle(getResources().getString(2131427728));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        InviteActivity.this.finish();
      }
    });
  }

  private void postMoreAlreadyListPie()
  {
    if ((this.f_newList != null) && (this.f_newList.size() > 0))
    {
      Iterator localIterator = this.f_newList.iterator();
      while (true)
      {
        if (!localIterator.hasNext())
        {
          this.textview_invite_sumfriends.setText(getString(2131427723) + PageBean.totalRecord + getString(2131427724));
          this.fAdapter.notifyDataSetChanged();
          this.f_newList = null;
          return;
        }
        InviteFriendBean localInviteFriendBean = (InviteFriendBean)localIterator.next();
        this.fAdapter.add(localInviteFriendBean);
      }
    }
    this.page = (-1 + this.page);
    alertMessage(getString(2131427519));
  }

  private void postMoreSuccessListPie()
  {
    if ((this.f_newList_suc != null) && (this.f_newList_suc.size() > 0))
    {
      Iterator localIterator = this.f_newList_suc.iterator();
      while (true)
      {
        if (!localIterator.hasNext())
        {
          this.textview_invite_sumfriends.setText(getString(2131427723) + PageBean.totalRecord + getString(2131427724));
          this.fAdapter.notifyDataSetChanged();
          this.f_newList_suc = null;
          return;
        }
        InviteFriendBean localInviteFriendBean = (InviteFriendBean)localIterator.next();
        this.fAdapter.add(localInviteFriendBean);
      }
    }
    this.page = (-1 + this.page);
    alertMessage(getString(2131427519));
  }

  private void showAlready()
  {
    this.Logchange = 1;
    this.tf_line_already.setVisibility(0);
    this.tf_line_success.setVisibility(8);
    new InviteAsyncTask().execute(new String[] { "init" });
  }

  private void showSuccess()
  {
    this.Logchange = 2;
    this.tf_line_already.setVisibility(8);
    this.tf_line_success.setVisibility(0);
    new InviteAsyncTask().execute(new String[] { "success" });
  }

  protected void backKeyCallBack()
  {
    super.backKeyCallBack();
    finish();
  }

  public void onBackPressed()
  {
    super.onBackPressed();
    finish();
  }

  public void onClick(View paramView)
  {
    switch (paramView.getId())
    {
    default:
      return;
    case 2131493138:
      showAlready();
      return;
    case 2131493139:
      showSuccess();
      return;
    case 2131493149:
    }
    IntentActivity(this, SmsMessageActivity.class);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903115);
    init();
    initActionBar();
    addListener();
  }

  protected void onResume()
  {
    super.onResume();
    if (this.Logchange == 1)
    {
      showAlready();
      return;
    }
    showSuccess();
  }

  public class InviteAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public InviteAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("init"))
        return InviteActivity.this.bgInitAlreadyList();
      if (this.method.equals("refash"))
        return InviteActivity.this.bgInitAlreadyList();
      if (this.method.equals("success"))
        return InviteActivity.this.bgInitSuccessList();
      if (this.method.equals("more"))
      {
        if (InviteActivity.this.Logchange == 1)
          return InviteActivity.this.bgMoreAlreadyList();
        return InviteActivity.this.bgMoreSuccessList();
      }
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("init"))
        InviteActivity.this.bgShowAlready();
      while (true)
      {
        InviteActivity.this.v_progressDialog.dismiss();
        return;
        if (this.method.equals("refash"))
          InviteActivity.this.bgShowAlready();
        else if (this.method.equals("success"))
          InviteActivity.this.bgShowAlready();
        else if (this.method.equals("more"))
          if (InviteActivity.this.Logchange == 1)
            InviteActivity.this.postMoreAlreadyListPie();
          else
            InviteActivity.this.postMoreSuccessListPie();
      }
    }

    protected void onPreExecute()
    {
      InviteActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.InviteActivity
 * JD-Core Version:    0.6.2
 */